package com.hl.mapper;

import com.hl.pojo.PublicWelfare;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface PublicWelfareMapper {
    // 添加公益信息
    @Insert("insert into public_welfare (title, intro, list_image, detail_content, create_time) values (#{title}, #{intro}, #{listImage}, #{detailContent}, #{createTime})")
    public Integer add(PublicWelfare publicWelfare);

    // 查询所有公益信息（未删除）
    @Select("select * from public_welfare where del = 0")
    public List<PublicWelfare> findAll();

    // 根据id删除公益信息（软删除）
    @Update("update public_welfare set del = 1 where id = #{id}")
    public Integer del(Integer id);

    // 根据id查询公益信息
    @Select("select * from public_welfare where id = #{id}")
    public PublicWelfare findById(Integer id);

    // 更新公益信息
    @Update("update public_welfare set title=#{title}, intro=#{intro}, list_image=#{listImage}, detail_content=#{detailContent} where id=#{id}")
    public Integer update(PublicWelfare publicWelfare);
}
